package com.waves.oss.controller;

import com.waves.core.web.domain.R;
import com.waves.oss.service.OssService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * Created by dlw
 */
@Api(value = "阿里云oss上传", tags = {"阿里云oss"})
@RestController
@RequestMapping("/oss/files")
public class OssController {

    @Resource
    private OssService ossService;

    //上传图片的方法
    @PostMapping
    public R<Object> uploadOssFile(@RequestPart("file")MultipartFile file){
        // 返回上传到oss的路径
        return R.ok(ossService.uploadFileAvatar(file));
    }

}